import java.util.HashMap;
import java.util.Map;

public class Solution1814 {
    public int countNicePairs(int[] nums) {
        Map<Integer,Integer> map=new HashMap<>();
        for (int num : nums) {
            int t=num-cal(num);
            map.put(t,map.getOrDefault(t,0)+1);
        }
        long ans=0;
        for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
            long t=entry.getValue();
            ans+=t*(t-1)/2;
        }
        return (int)(ans%1000000007);
    }

    private int cal(int num) {
        return Integer.parseInt(new StringBuilder(String.valueOf(num)).reverse().toString());
    }

    public static void main(String[] args) {
        System.out.println(new Solution1814().countNicePairs(new int[]{42,11,1,97}));
    }
}
